from collections import deque


class MyQueue:
    def __init__(self):
        self.s1, self.s2 = deque(), deque()

    def push(self, num):
        self.s1.append(num)

    def pop(self):
        if not self.s2 and not self.s1:
            raise Exception('栈为空')
        elif not self.s2:
            # 把s1放入s2
            while self.s1:
                self.s2.append(self.s1.pop())
        return self.s2.pop()


myQueue = MyQueue()
myQueue.push(1)
myQueue.push(2)
myQueue.push(3)
print(myQueue.pop())
